#include "gtest/gtest.h"

#include "SevenRecordTopic.h"

using namespace stream;

class SequenceReaderTest : public testing::Test {
public:
    void SetUp() override{
        _7record  = new SevenRecordTopic();
    }
	void TearDown() override{
		delete _7record;
		_7record = nullptr;
	}
protected:
    SevenRecordTopic * _7record = nullptr;
};

#include "stream/SequenceReader.h"
TEST_F(SequenceReaderTest, testMock){
	auto reader = std::shared_ptr<SequenceReader>(::stream::makeSequenceReaderMock(_7record->topic(), 0ull));
	ASSERT_TRUE(reader->open());
    size_t count = 0;
	while(reader->hasNext()){
        auto && cur = reader->current();
		std::cout << cur.first << ":" << cur.second << std::endl;
        ++ count;
        reader->next();
	}
    ASSERT_EQ(3ull, count);

	reader->close();
}
TEST_F(SequenceReaderTest, testTopic){
	auto reader = std::shared_ptr<SequenceReader>(::stream::makeSequenceReader(_7record->topic(), 0ull));
	ASSERT_TRUE(reader->open());
    size_t count = 0;
	while(reader->hasNext()){
        reader->current();
		//std::cout << cur.first << ":" << cur.second << std::endl;
        ++count;
        reader->next();
	}
    ASSERT_EQ(_7record->expectRecord(), count);
	reader->close();
}
